﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using Billing.Controls;
using Billing.Utilities;
using System.Configuration;

namespace Billing
{
    public partial class CouponPrinter : Form
    {
        PaperSize psize;
        string BillNo;
        string ItemName;
        string Qty;

        public CouponPrinter(string billNo, string itemName, string qty)
        {
            InitializeComponent();
            BillNo = billNo.ToUpper();
            ItemName = itemName;
            Qty = qty;
        }

        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            e.PageSettings.PaperSize = psize;
            e.Graphics.DrawString("KS BAKERS", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 100, 0);
            e.Graphics.DrawString(ConfigurationManager.AppSettings["ColonyName"], new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 15, 15);
            e.Graphics.DrawString(ConfigurationManager.AppSettings["TinNo"], new Font(new FontFamily("Times New Roman"), 11, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 80, 30);
            e.Graphics.DrawString("Date : " + DateTime.Now.ToString("dd/MM/yy") + "  " + DateTime.Now.ToShortTimeString() + "    Bill No:" + BillNo, new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, 50);
            e.Graphics.DrawString("Cashier Name : " + Storage.LoginUser, new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, 65);

            int lineCounter = 75;
            e.Graphics.DrawString("--------------------------------------------------------------", new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, lineCounter);
            lineCounter += 15;

            e.Graphics.DrawString("       " + ItemName + "        " + Qty, new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, lineCounter);

            lineCounter += 20;
            e.Graphics.DrawString("Thank You", new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 115, lineCounter + 5);
            e.Graphics.RotateTransform(-20);
            e.Graphics.DrawString("COUPON", new Font(new FontFamily("Times New Roman"), 35, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.LightGray, 0, 70);
            e.Graphics.ResetTransform();
        }

        private void printDocument1_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e)
        {
            psize = new PaperSize("saurabh", 300, 165);
            e.PageSettings.PaperSize = psize;
        }
    }
}
